﻿using SqlSugar;

namespace Forum.Entity.CodeFirst.model
{
    /// <summary>
    /// 文章类别
    /// </summary>
    [SugarTable("Category")]
    public class Category
    {
        [SugarColumn(IsPrimaryKey = true, IsIdentity = true)]//如果是主键，此处必须指定，否则会引发InSingle(id)方法异常。
        public int Id { get; set; }

        public string Name { get; set; }

        public int ParentId { get; set; }

        [SugarColumn(IsIgnore = true)]
        public Category? Parent { get; set; }

        /// <summary>
        /// 分类是否可见
        /// </summary>
        public bool Visible { get; set; } = true;

        [SugarColumn(IsIgnore = true)]
        public List<Post> Posts { get; set; }
    }
}